import router from './router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import getPageTitle from '@/utils/get-page-title'

NProgress.configure({ showSpinner: false })

// 路由守卫，进入路由
router.beforeEach(async(to, from, next) => {
  // 虚拟进度条开启
  NProgress.start()

  document.title = getPageTitle(to.meta.title)

  next()
})

// 路由守卫，进入路由成功以后， 一般只需要写这两个钩子函数
router.afterEach(() => {
  // 虚拟进度条结束
  NProgress.done()
})
